package ru.usu.gv.gui.analysis;

import ru.usu.gv.core.GraphCanvas;
import ru.usu.gv.uicomponents.UIEdge;
import ru.usu.gv.uicomponents.UIGraph;

import java.util.List;

/**
 @author Sergey Pupyrev 
 13.04.2007
 */

public class BendAnalyzer extends GraphAnalyzer
{

	public BendAnalyzer()
	{
		super(AnalysisPanel.getInstance().getBendSlider());
	}

	@Override
	protected double calculateAnalysValue()
	{
		UIGraph uiGraph = GraphCanvas.getInstance().getCurrentGraph();
		List<UIEdge> edges = uiGraph.getEdges();

		int countEdges = edges.size();
		int countBends = 0;
		for (UIEdge edge : edges)
		{
			countBends += edge.getViewItem().getControlPoints().length + 1;
		}

		return (double) countEdges / countBends;
	}

}
